# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: mrxx <mrxx at cyberhome dot at>
# Contributor: Limao Luo <luolimao+AUR@gmail.com>
# Contributor: sausageandeggs <sausageandeggs@archlinux.us>

pkgname=playitslowly
pkgver=1.5.1
pkgrel=11
pkgdesc='Play back audio files at a different speed or pitch'
arch=('any')
url='https://29a.ch/playitslowly'
license=('GPL3')
depends=('gst-plugins-bad' 'gst-plugins-base' 'gst-plugins-good' 'gst-python' 'gtk3'
         'python-gobject')
optdepends=('gst-plugins-ugly: Extra media codecs'
            'gst-libav: Extra media codecs')
source=("http://29a.ch/$pkgname/$pkgname-$pkgver.tar.gz"
        'python310.patch'
        'gtk-version.patch'
        'playitslowly.appdata.xml')
sha256sums=('7dfe3da5417971183a13002d1e4ba4f30770baaf1ae3f9ef0ac66a6727f476aa'
            '007fa2535e058894adaa31422be6b64106cb9d61b1e726fd53363ab516ce77f2'
            '397b430ad7bc16c606e466d53000c5c4ac57ee0b5390ddd8276bf46dbc17dd26'
            'ebe2890f7e42dfb7988d4304a4faee6d5657556f12bcebcd3279e9de86ec1ae4')

prepare() {
  cd $pkgname-$pkgver

  # Correct 'site-packages/playitslowly-py3.1.install-info' filename
  patch -Np1 -i ../python310.patch

  # Specify required GTK version
  patch -Np1 -i ../gtk-version.patch

  # Move files to their right places
  mkdir -p share/icons/hicolor/{32x32,128x128,scalable}/apps share/metainfo
  mv share/pixmaps/playitslowly.png share/icons/hicolor/128x128/apps/playitslowly.png
  mv share/icons/hicolor/32x32/playitslowly.png share/icons/hicolor/32x32/apps/playitslowly.png
  mv share/icons/hicolor/scalable/playitslowly.svg \
    share/icons/hicolor/scalable/apps/playitslowly.svg
  cp ../playitslowly.appdata.xml share/metainfo/playitslowly.appdata.xml
  rm -r share/pixmaps
}

build() {
  cd $pkgname-$pkgver
  python setup.py build
}

package() {
  cd $pkgname-$pkgver
  python setup.py install --root="$pkgdir" --optimize=1 --skip-build
}
